<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/11/25
  Time: 14:36
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/layuicms2.0/layui/css/layui.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/layuicms2.0/layui_ext/dtree/dtree.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/layuicms2.0/layui_ext/dtree/font/dtreefont.css">
</head>
<body class="childrenBody">
<!-- 搜索条件开始 -->
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>查询条件</legend>
</fieldset>
<form class="layui-form" method="post" id="searchFrm">

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">出租单号:</label>
            <div class="layui-input-inline" style="padding: 5px">
                <input type="text" name="rentid" id="rentid" autocomplete="off" class="layui-input layui-input-inline"
                       placeholder="请输入出租单号" style="height: 30px;border-radius: 10px">
            </div>
        </div>

        <div class="layui-inline" style="text-align: center">
            <button type="button"
                    class="layui-btn layui-btn-normal layui-icon layui-icon-search layui-btn-radius layui-btn-sm"
                    lay-submit  lay-filter="doSearch" style="margin-top: 4px">查询
            </button>
            <button type="reset"
                    class="layui-btn layui-btn-warm layui-icon layui-icon-refresh layui-btn-radius layui-btn-sm"
                    style="margin-top: 4px">重置
            </button>
        </div>
    </div>

</form>


<div id="content" style="display: none">
    <blockquote class="layui-elem-quote" style="margin-top: 10px">
        <div id="test2">
            检查单表单
        </div>
    </blockquote>
    <form class="layui-form" method="post" id="checkFrm" lay-filter="checkFrm">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">检查单号:</label>
                <div class="layui-input-inline" style="padding: 5px;width: 280px">
                    <input type="text" name="checkid" id="checkid" readonly="readonly"
                           class="layui-input layui-input-inline"
                           placeholder="请输入检查单号" style="height: 30px;border-radius: 10px;width: 280px">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">出租单号:</label>
                <div class="layui-input-inline" style="padding: 5px;width: 280px">
                    <input type="text" name="rentid" id="rentid2" readonly="readonly" autocomplete="off"
                           class="layui-input layui-input-inline"
                           placeholder="请输入出租单号" style="height: 30px;border-radius: 10px;width: 280px">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">操作员:</label>
                <div class="layui-input-inline" style="padding: 5px;width: 280px">
                    <input type="text" name="openname" id="openname" readonly="readonly" autocomplete="off"
                           class="layui-input layui-input-inline"
                           placeholder="请输入操作员" style="height: 30px;border-radius: 10px;width: 280px">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">存在问题:</label>
                <div class="layui-input-inline" style="padding: 5px;width: 280px">
                    <input type="text" name="problem" id="problem" required  lay-verify="required" autocomplete="off"
                           class="layui-input layui-input-inline"
                           placeholder="请输入存在的问题" style="height: 30px;border-radius: 10px;width: 280px">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">赔付金额:</label>
                <div class="layui-input-inline" style="padding: 5px;width: 280px">
                    <input type="text" name="paymoney" id="paymoney" required  lay-verify="required" autocomplete="off"
                           class="layui-input layui-input-inline"
                           placeholder="请输入赔付金额" style="height: 30px;border-radius: 10px;width: 280px">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">检查时间:</label>
                <div class="layui-input-inline" style="padding: 5px;width: 280px">
                    <input type="text" name="checkdate1" id="checkdate" required  lay-verify="required"
                           class="layui-input layui-input-inline"
                           placeholder="请输入检查时间" style="height: 30px;border-radius: 10px;width: 280px">
                </div>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">问题描述:</label>
            <div class="layui-input-block" id="checkdesc">
                <textarea name="checkdesc" placeholder="请输入问题描述" required  lay-verify="required" class="layui-textarea"></textarea>
            </div>
        </div>
        <div class="layui-form-item" style="text-align: center">
            <button type="button" lay-submit="" lay-filter="doSubmit"
                    class="layui-btn layui-btn-normal layui-icon layui-icon-release layui-btn-radius layui-btn-sm"
                    lay-filter="doSubmit" lay-submit="" style="margin-top: 4px">保存
            </button>
        </div>
    </form>
    <%--出租单信息，车辆信息，客户信息的展示--%>
    <div style="padding: 10px; background-color: #F2F2F2;">
        <div class="layui-row layui-col-space10">
            <div class="layui-col-md4 layui-col-sm4">
                <div class="layui-card">
                    <div class="layui-card-header">车辆信息</div>
                    <div class="layui-card-body" id="car_carnumber"></div>
                    <div class="layui-card-body" id="car_cartype"></div>
                    <div class="layui-card-body" id="car_color"></div>
                    <div class="layui-card-body" id="car_price"></div>
                    <div class="layui-card-body" id="car_rentprice"></div>
                    <div class="layui-card-body" id="car_deposit"></div>
                    <div class="layui-card-body" id="car_description"></div>
                    <div class="layui-card-body">
                        车辆图片：<img src="" width="200" height="150" id="car_carimg">
                    </div>
                </div>
            </div>
            <div class="layui-col-md4 layui-col-sm4">
                <div class="layui-card">
                    <div class="layui-card-header">出租单信息</div>
                    <div class="layui-card-body" id="rent_rentid"></div>
                    <div class="layui-card-body" id="rent_price"></div>
                    <div class="layui-card-body" id="rent_begindate"></div>
                    <div class="layui-card-body" id="rent_returndate"></div>
                    <div class="layui-card-body" id="rent_openname"></div>
                </div>
            </div>
            <div class="layui-col-md4 layui-col-sm4">
                <div class="layui-card">
                    <div class="layui-card-header">客户信息</div>
                    <div class="layui-card-body" id="customer_identity"></div>
                    <div class="layui-card-body" id="customer_custname"></div>
                    <div class="layui-card-body" id="customer_sex">客户性别：${customer.sex==1?"女":"男"}</div>
                    <div class="layui-card-body" id="customer_address"></div>
                    <div class="layui-card-body" id="customer_phone"></div>
                    <div class="layui-card-body" id="customer_career"></div>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="${pageContext.request.contextPath}/static/layuicms2.0/layui/layui.js"></script>
    <script>
        var logTree;
        var carTable;
        var miniIndex;
        var url;
        var demoTree;
        layui.extend({
            dtree: '${pageContext.request.contextPath}/static/layuicms2.0/layui_ext/dtree/dtree'   // {/}的意思即代表采用自有路径，即不跟随 base 路径
        }).use(['table','form','layer','jquery','dtree','laydate'], function(){
            var table = layui.table
            var form = layui.form
            var layer = layui.layer
            var $ = layui.jquery
            var dtree = layui.dtree
            var laydate = layui.laydate

            // form表单提交  -- 查询功能
            form.on("submit(doSearch)",function(data) {
                $.post("/car/check/init",{"rentid":data.field.rentid},function (r) {
                    if (r.code==-1){
                        layer.msg(r.msg)
                        $("#content").css("display","none")
                    }else{
                        $("#content").css("display","block")//把div隐藏属性改成显示
                        //给检查表单赋值
                        $("#checkid").val(time1())
                        $("#rentid2").val(r.data.checkVo1.rentid)
                        $("#openname").val(r.data.checkVo1.openname)
                        $("#paymoney").val(0)
                        $("#checkdate").val(time())



                        //给车辆信息赋值

                         $("#car_carnumber").html("车辆编号："+r.data.car.carnumber)
                        $("#car_cartype").html("车辆类型："+r.data.car.cartype)
                        $("#car_color").html("车辆颜色："+r.data.car.color)
                        $("#car_price").html("车辆价格："+r.data.car.price)
                        $("#car_rentprice").html("出租价格："+r.data.car.rentprice)
                        $("#car_deposit").html("车辆押金："+r.data.car.deposit)
                        $("#car_description").html("车辆描述："+r.data.car.description)
                        $("#car_carimg").attr("src",r.data.car.carimg)


                        //给出租单信息赋值

                       $("#rent_rentid").html("出租单号："+r.data.checkVo1.rentid)
                        $("#rent_price").html("出租价格："+r.data.car.rentprice)
                        $("#rent_begindate").html("租车时间："+r.data.checkVo1.begindate)
                        $("#rent_returndate").html("还车时间："+r.data.checkVo1.returndate)
                        $("#rent_openname").html("操作人："+r.data.checkVo1.openname)

                        //给客户信息赋值
                        var rentid=$("#rent_rentid").html()
                        var carnumber=$("#car_carnumber").html()

                        $("#customer_identity").html("身份编号："+r.data.customer.identity)
                        $("#customer_custname").html("客户姓名："+r.data.customer.custname)
                        <%--$("#customer_sex").html("客户性别："+r.data.user.sex)--%>
                        <%--${user==null?true:false}--%>
                        $("#customer_address").html("客户地址："+r.data.customer.address)
                        $("#customer_phone").html("客户电话："+r.data.customer.phone)
                        $("#customer_career").html("职位："+r.data.customer.career)

                    }

                })

                return false;
            })


            form.on('submit(doSubmit)', function (data) {
                $.post("/car/check/add", data.field, function (r) {
                    if (r.code == 0) {
                        console.info(r.msg)
                        layer.msg(r.msg, {icon: 1})
                        layer.msg(r.msg)
                    } else {
                        layer.msg(r.msg, {icon: 2})
                    }
                })
                return false;
            })




            
            function time() {
              var time=  new Date()
                var h=time.getFullYear()
                var m=time.getMonth()+1
                var d=time.getDate()
                if(d<10){
                    d="0"+time.getDate()
                }
                var H=time.getHours()
                var M=time.getMinutes()
                var s=time.getSeconds()
                if(s<10){
                    s="0"+time.getSeconds()
                }
                var  ss=time.getMilliseconds()
                return h+"-"+m+"-"+d+" "+H+":"+M+":"+s

            }
            function time1() {
                var time=  new Date()
                var h=time.getFullYear()
                var m=time.getMonth()+1
                var d=time.getDate()
                if(d<10){
                    d="0"+time.getDate()
                }
                var H=time.getHours()
                var M=time.getMinutes()
                var s=time.getSeconds()
                var  ss=time.getMilliseconds()
                var sj=  parseInt(Math.random()*100000)
                return "JC_"+h+""+m+""+d+"_"+H+""+M+""+s+"_"+ss+"_"+sj

            }




        });


    </script>
</body>
</html>
